package com.bluedot.www.baiyetest.servlet.baiyetest;

import java.awt.image.BufferedImage;

import com.bluedot.www.core.common.OSSConfigure;
import com.bluedot.www.core.pojo.BO.MailBo;
import com.bluedot.www.core.utils.DbUtil;
import com.bluedot.www.core.utils.MailUtil;
import com.bluedot.www.core.utils.OSSManageUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectStreamClass;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author jiangnan
 * @version 1.0
 * @date 2021/8/11 20:28
 */
public class test {
    public static void main(String[] args) throws IOException, InterruptedException {


   /*     FileInputStream in = new FileInputStream("F:\\java\\project\\handwritingAnalysisSys\\src\\main\\resources\\");

        InputStream in2 = Resources.getResourceAsStream("SqlMapConfig.xml");


        System.out.println(in);
        System.out.println();
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);

        SqlSession sqlSession = sqlSessionFactory.openSession();

        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        String eamil = "111";
        String password = "ddsds";
        Integer integer = mapper.insertUser(eamil, password);

        System.out.println(integer);*/

    /*    String sources = "0123456789";
        Random rand = new Random();
        StringBuffer flag = new StringBuffer();
        for (int j = 0; j < 6; j++)
        {
            flag.append(sources.charAt(rand.nextInt(9)) + "");
        }

        System.out.println(flag);*/


       /* String emailrule ="^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";

        System.out.println("1113049408qq.com".matches(emailrule));*/

/*
        long time1 = DbUtil.getCurrentTime().getTime();
        System.out.println(time1);
        Thread.sleep(100000);

        long time2 = DbUtil.getCurrentTime().getTime();
        System.out.println(time2);
        int Minutes = (int)(time2 - time1) / (1000 * 60 );
        System.out.println(Minutes);*/



//
//         Map<String, List> map = new HashMap<>();
//        List<String> list = new ArrayList<>();
//        list.add("8");
//        list.add("765756");
//        map.put("1113049@qq.com",list);
//        List<String> list2 = new ArrayList<>();
//        list2.add("11");
//        list2.add("423423");
//        map.put("1113012@qq.com",list2);
//
//        for(String key:map.keySet()){
//            String time = (String)map.get(key).get(0);
//            if ( Integer.parseInt(time)<9){
//             map.remove(key);
//            }
//        }
//        System.out.println(map);
 /*       String dir = "C:\\Users\\白夜\\BlueDotProject\\handwritingAnalysisSys\\web\\WEB-INF\\lib\\test-1.0-SNAPSHOT.jar";
//        String jarName = "file:"+dir;
//        System.out.println(jarName);
        File file = new File(dir);
        System.out.println(file.exists());
        URL url = file.toURL();
        try {
            URLClassLoader loader = new URLClassLoader(new URL[]{url});

            Class<?> clazz = loader.loadClass("com.baiye.www.AlgorithmHandler");
            Object o = clazz.newInstance();
            Method method = clazz.getDeclaredMethod("preHandleImage");
            method.invoke(o);
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
            e.printStackTrace();
        }*/


      /*  System.out.println(DbUtil.getMd5("123"));
        System.out.println(DbUtil.getMd5("123"));*/




//         OSSManageUtil.copy();

//        oss文件上传
    /*    FileInputStream in = new FileInputStream("F:\\2.png");
        String s = OSSManageUtil.uploadFile(in, "2.png", "bluedot/portrait/");

*/

//         邮件发送例子
//
//        File file = new File(test.class.getResource("/").getPath());
//        String html = MailUtil.readHTML(file);
//        MailBo mailBo = new MailBo("1113049408@qq.com", "Verification",html,"欢迎注册",MailUtil.getCode());
//        MailUtil.sendMail("application.properties", mailBo);

/*

       String content =  MailUtil.readHTML("F:\\java\\project\\handwritingAnalysisSys\\src\\main\\resources\\static\\apply.html");
        String ss=content.replace("${title}","心理咨询师申请")
                .replace("${username}","1113049408@qq.com")
                .replace("${result}","恭喜你，通过心理咨询师申请！")
                .replace("${note}","无");

        MailBo mailBo = new MailBo("1113049408@qq.com", "apply", ss);;
        MailUtil.sendMail("application.properties", mailBo);
*/


//        System.out.println(UUID.randomUUID().toString());//63a87540-2f83-43e3-8e3a-e6c1061eea99


      /*  BufferedImage transfor = OSSManageUtil.transfor("bluedot/portrait/21-10-18_3d3b1480c9da45138c9e62de26f799a9.png");
        System.out.println(transfor);*/

        System.out.println(DbUtil.getMd5("2131231232131"));
    }
}
